<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>计算器</title>
</head>
<body>
	<input type="text" id="first">
	<input type="text" id="fu" style="width: 20px">
	<input type="text" id="second">
	=
	<input type="text" id="result" readonly="readonly">
    <button onclick="jisuan()">计算</button>
	<script>
		function jisuan(){
			var first = parseInt(document.getElementById('first').value);
			var second = parseInt(document.getElementById('second').value);
			var fu = document.getElementById('fu').value;
			var result = 0
			switch (fu) {
				case '+':
					result = first + second;
					break;
				case '-':
				    result = first - second;
				    break;
				case '*':
				    result = first * second;
				    break;
				case '/':
				    if(second != 0){
				    	result = first / second;
				    }
				    else{
				    	alert('被除数不能为0');
				    }
				    break;
				default:
					alert('运算符错误！')
					break;
			}
			

			document.getElementById('result').value = result;
		}
	</script>
</body>
</html>